<?php
/***************************************************************************
 *
 *   copyright            : (C) 2005 Winds of Storm
 *
 *   $Id: main.php,v 1.15 2007/01/30 21:02:43 nathan Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

require("config.php");
$skip_header    = 1;
require($libdir . "init." . $phpEx);
require($libdir . "rooms." . $phpEx);

$room_name  = getRoomNameBySession($_REQUEST['sid']);

$sid    = $_REQUEST['sid'];
$sql    = "SELECT * FROM {$dbprefix}sessions WHERE session_id='$sid'";
$result = $db->sql_query($sql);
$row    = $db->sql_fetchrow($result);

$userid = $row['user_id'];

$sql    = "SELECT * FROM {$dbprefix}prefs WHERE user_id=$userid";
$res    = $db->sql_query($sql);
$p_row  = $db->sql_fetchrow($res);


$row2   = "5%,85%,10%,0%";
if ($p_row['user_frames1'] != '') {
    $row2   = $p_row['user_frames1'];
}
if ($_REQUEST['cpsp'] == MODE_CLIENT_PULL) {
    $row2   .= ",0%";
}

$row3   = "*,140";
if ($p_row['user_frames2'] != '') {
    $row3   = $p_row['user_frames2'];
}

$template = new Template($config['TPL_DIR']);
$template->set_filenames(array('body' => 'main_body.tpl'));

$template->assign_vars(array(
    'ROOM_NAME'     => $room_name,
    'SID'           => $_REQUEST['sid'],
    'CPSP'          => $_REQUEST['cpsp'],

    'FR_ROW2'       => $row2,
    'FR_ROW3'       => $row3,

    'CHAT_SERVER'   => $config['CHAT_SERVER'],
    'CHAT_PORT'     => $config['CHAT_PORT'],

    'PHPEX'         => $phpEx
));

switch ($_REQUEST['cpsp']) {
    case MODE_SLIMCHAT:
        $template->assign_block_vars('switch_slim', array());
        break;
    case MODE_CLIENT_PULL:
        $template->assign_block_vars('switch_notslim', array());
        $template->assign_block_vars('switch_notslim.switch_pull', array());
        break;
    case MODE_SERVER_PUSH_PROXY:
        $template->assign_block_vars('switch_notslim', array());
        $template->assign_block_vars('switch_notslim.switch_push_proxy', array());
        break;
    case MODE_SERVER_PUSH:
        $template->assign_block_vars('switch_notslim', array());
        $template->assign_block_vars('switch_notslim.switch_push', array());
        break;
}


$template->pparse('body');

